home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.0 / stk-3 / blt-for-STk-3.0 / blt-1.9 / src / bltGrElem.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-01  |  5.7 KB  |  158 lines

  1.  
  2. /*
  3.  * bltGrElem.h --
  4.  *
  5.  * Copyright 1991-1994 by AT&T Bell Laboratories.
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for any purpose and without fee is hereby
  8.  * granted, provided that the above copyright notice appear in all
  9.  * copies and that both that the copyright notice and warranty
  10.  * disclaimer appear in supporting documentation, and that the
  11.  * names of AT&T Bell Laboratories any of their entities not be used
  12.  * in advertising or publicity pertaining to distribution of the
  13.  * software without specific, written prior permission.
  14.  *
  15.  * AT&T disclaims all warranties with regard to this software, including
  16.  * all implied warranties of merchantability and fitness.  In no event
  17.  * shall AT&T be liable for any special, indirect or consequential
  18.  * damages or any damages whatsoever resulting from loss of use, data
  19.  * or profits, whether in an action of contract, negligence or other
  20.  * tortuous action, arising out of or in connection with the use or
  21.  * performance of this software.
  22.  *
  23.  */
  24.  
  25. #ifndef _ELEMENT_H
  26. #define _ELEMENT_H
  27.  
  28. #define DEF_ACTIVE_SIZE 8    /* Default size of the static active
  29.                  * array.  Contains indices of the
  30.                  * active data points within an element */
  31.  
  32.  
  33. typedef enum {
  34.     ELEM_NORMAL, ELEM_ACTIVE
  35. } ElementActiveStates;
  36.  
  37. /*
  38.  * An element can be a line or a bar.
  39.  */
  40. typedef enum {
  41.     LINE_ELEM_TYPE, BAR_ELEM_TYPE
  42. } ElementClassType;
  43.  
  44. /*
  45.  * It can have one of the following types of symbol.
  46.  */
  47. typedef enum {
  48.     LINE_SYMBOL, SQUARE_SYMBOL, CIRCLE_SYMBOL, DIAMOND_SYMBOL,
  49.     PLUS_SYMBOL, CROSS_SYMBOL, SPLUS_SYMBOL, SCROSS_SYMBOL
  50. } SymbolType;
  51.  
  52. /*
  53.  * The data structure below contains information pertaining to a line
  54.  * vector.  It consists of an array of floating point data values and
  55.  * for convenience, the number and minimum/maximum values.
  56.  */
  57. typedef struct Vector {
  58.     double *data;        /* Array of values */
  59.     unsigned int length;    /* Number of entries in the array */
  60.     unsigned int size;        /* Size of data array allocated */
  61.     double min, max;        /* Smallest/largest values in the array */
  62.     double logMin;        /* Smallest positive value */
  63. } Vector;
  64.  
  65. /*
  66.  * An element has one or more vectors plus several attributes,
  67.  * such as line style, thickness, color, and symbol type.  It
  68.  * has an identifier which distinguishes it among the list of all
  69.  * elements.
  70.  */
  71. typedef struct Element Element;
  72. typedef struct ClosestPoint ClosestPoint;
  73.  
  74. typedef void (ElemDisplayProc) _ANSI_ARGS_((Graph *graphPtr, Element *elemPtr,
  75.     int active));
  76. typedef void (ElemPrintProc) _ANSI_ARGS_((Graph *graphPtr, Element *elemPtr,
  77.     int active));
  78. typedef void (ElemDestroyProc) _ANSI_ARGS_((Graph *graphPtr,
  79.     Element *elemPtr));
  80. typedef int (ElemConfigProc) _ANSI_ARGS_((Graph *graphPtr, Element *elemPtr));
  81. typedef void (ElemLayoutProc) _ANSI_ARGS_((Graph *graphPtr, Element *elemPtr));
  82. typedef int (ElemLimitsProc) _ANSI_ARGS_((Graph *graphPtr, Element *elemPtr,
  83.     GraphAxis *axisPtr, double *minPtr, double *maxPtr));
  84. typedef int (ElemDistanceProc) _ANSI_ARGS_((Graph *graphPtr,
  85.     Element *elemPtr, int x, int y, ClosestPoint * closePtr));
  86. typedef void (ElemDrawSymbolsProc) _ANSI_ARGS_((Graph *graphPtr,
  87.     Element *elemPtr, int symbolSize, XPoint *pointArr, int numPoints,
  88.     int active));
  89. typedef void (ElemPrintSymbolsProc) _ANSI_ARGS_((Graph *graphPtr,
  90.     Element *elemPtr, int symbolSize, XPoint *pointArr, int numPoints,
  91.     int active));
  92.  
  93. struct Element {
  94.     Tcl_Interp *interp;        /* Interpreter of graph widget */
  95.     ElementClassType type;    /* Type of element; either BAR_ELEMENT or
  96.                  * LINE_ELEMENT */
  97.     unsigned int flags;
  98.     Tk_Uid id;            /* Identifier to refer the element. Used in
  99.                  * the "insert", "delete", or "show",
  100.                  * commands. */
  101.     int mapped;            /* If true, element is currently visible. */
  102.     Tk_ConfigSpec *configSpecs;    /* Configuration specifications */
  103.     char *label;        /* Label displayed in legend */
  104.     SymbolType symbol;        /* Element symbol type */
  105.     double symbolScale;        /* Size of symbol as a percentage of the
  106.                  * drawing area. */
  107.     unsigned int symbolSize;    /* Computed size of symbol in pixels. */
  108.  
  109.     Vector x, y;        /* Contains array of floating point graph
  110.                  * coordinate values. Also holds min/max and
  111.                  * the number of coordinates */
  112.     unsigned int axisFlags;    /* Indicates which axes to map element's
  113.                  * coordinates onto */
  114.     int *activeArr;        /* Array of indices of active data
  115.                  * points (malloc-ed). Initially points
  116.                  * to static storage "staticArr". */
  117.     int staticArr[DEF_ACTIVE_SIZE];
  118.     int numActivePoints;    /* Number of active data points. If
  119.                  * zero and active bit is set in
  120.                  * "flags", then all data points are
  121.                  * active. */
  122.  
  123.     ElemConfigProc *configProc;
  124.     ElemDestroyProc *destroyProc;
  125.     ElemDisplayProc *displayProc;
  126.     ElemLimitsProc *limitsProc;
  127.     ElemDistanceProc *closestProc;
  128.     ElemLayoutProc *layoutProc;
  129.     ElemPrintProc *printProc;
  130.     ElemDrawSymbolsProc *drawSymbolsProc;
  131.     ElemPrintSymbolsProc *printSymbolsProc;
  132. };
  133.  
  134. #define    LAYOUT_NEEDED     (1<<0)    /* Indicates that the element's
  135.                  * configuration has changed such that
  136.                  * its layout of the element (i.e. its
  137.                  * position in the graph window) needs
  138.                  * to be recalculated. */
  139.  
  140. #define    ACTIVE         (1<<8)    /* Non-zero indicates that the element
  141.                  * should be drawn in its active
  142.                  * foreground and background
  143.                  * colors. */
  144.  
  145. #define    LABEL_ACTIVE     (1<<9)    /* Non-zero indicates that the
  146.                  * element's entry in the legend
  147.                  * should be drawn in its active
  148.                  * foreground and background
  149.                  * colors. */
  150. struct ClosestPoint {
  151.     Element *elemPtr;        /* Closest element */
  152.     int index;            /* Index of closest data point */
  153.     double x, y;        /* Graph coordinates of closest point */
  154.     double dist;        /* Distance from the screen coordinates */
  155. };
  156.  
  157. #endif /* _ELEMENT_H */
  158.